package org.automated.realestatemanager.db.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "phones", uniqueConstraints = @UniqueConstraint(columnNames = { "phone" }))
public class Phone extends HasId implements Comparable<Phone> {

	private static final long serialVersionUID = 8012000240764736939L;

	public Phone() {
	}

	public Phone(final String phone) {
		this.phone = phone;
	}

	@Id
	@Column(name = "phone_id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long id;

	@Column(length = 12)
	private String phone;

	@Override
	public Long getId() {
		return id;
	}

	@Override
	public void setId(final Long id) {
		this.id = id;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(final String phone) {
		this.phone = phone;
	}

	public int compareTo(final Phone p) {
		return phone.compareTo(p.getPhone());
	}

	@Override
	public String toString() {
		return id + ":" + phone;
	}

}
